﻿#ifndef NSSHARE_SYS_BACkGROUND_THREAD
#define NSSHARE_SYS_BACkGROUND_THREAD

#include "../utils/disallow_copy_and_assign.h"
#include "../base/base_object.h"
#include "../sys/proactor.h"
#include "../sys/thread.h"

namespace nsshare
{
namespace sys
{

class BackgroundThread
    :public base::BaseObject
{
public:
    static bool Initialize();
    static void Uninitialize();
    static Proactor & IOHandler();
private:
    static BackgroundThread instance_;
private:
    BackgroundThread();
    ~BackgroundThread();

    bool Startup();
    void Shutdown();
    void IOProc();

    DISALLOW_COPY_AND_ASSIGN(BackgroundThread);
private:
    Proactor io_handler_;
    Thread io_thread_;
    ThreadProcAdapter<BackgroundThread> io_proc_;

    friend class BGIOThreadProc;
};

}
}

#endif